<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://unpkg.com/vuex@3.1.0/dist/vuex.js"></script>
    <script src="https://cdn.staticfile.org/vue/2.6.10/vue.min.js"></script>
    <script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
    <title>命名空间</title>
</head>
<body>
<div id="app">
    {{$store.getters}}
</div>
<script>
    const store = new Vuex.Store({
        modules: {
            account: {
                namespaced: true,
                state: {mod1: 'account'},
                getters: {getMod1:state=>state.mod1},
                modules: {
                    myPage: {
                        state: {mod2: 'myPage'},
                        getters: {getMod2:state=>state.mod2}
                    },

                    post: {
                        namespaced: true,
                        state: {mod1: 'post'},
                        getters: {
                            getMod2: state=>state.mod1
                        }
                    }
                }
            }
        }
    })
    new Vue({
        el: '#app',
        store
    })
</script>
</body>
</html>